<template>
  <view :class="[`${prefixCls}-list-block-container`]">
    <view class="room-container">
      <scroll-view class="scroll-view" scroll-x="true" style="width: 100%; white-space: nowrap">
        <view class="room-item">
          <view class="room-card" v-for="(item, index) in dataList" :key="index" @click="handleRoomDetail(item)">
            <image class="tab-video" :src="$CDN('/customer/static/images/icons/has-video.png')" />
            <image :src="item.cover" />
            <view class="room-name">{{ item.room_type_name }}</view>
            <view class="room-tag">
              <view class="tag-item" v-for="(items, indexs) in item.show_tag" :key="indexs">{{ items }}</view>
            </view>
            <view class="room-area">{{ item.district || '' + '|' + item.minArea || '' + 'm²起' }}</view>
            <view class="room-price">{{ item.minPrice }} <span class="unit"> 元/间/月起</span></view>
          </view>
        </view>
      </scroll-view>
    </view>
  </view>
</template>

<script>
import { mapActions, mapGetters } from 'vuex'

export default {
  name: 'componentName',
  components: {},
  mixins: [],
  props: {
    dataList: {
      type: Array,
      default: () => [],
    },
    type: {
      type: String,
      default: '',
    },
  },
  data() {
    return {}
  },
  // 侦听属性
  watch: {},
  // 计算属性
  computed: {
    ...mapGetters([]),
  },
  // 监听页面加载，该钩子被调用时data,computed,function,watch,props,slots已设置完成
  onLoad(options) {},
  // 监听页面显示，页面每次出现在屏幕上都触发
  onShow() {},
  // 监听页面初次渲染完成，此时组件已挂载完成
  onReady() {},
  // 下拉刷新
  onPullDownRefresh() {},
  // 加载更多
  onReachBottom() {},

  created() {},
  mounted() {},
  destroyed() {},
  methods: {
    ...mapActions([]),

    // 跳转至房间详情
    handleRoomDetail({ id, room_type_id, project_id }) {
      if (this.type == 'recommendProject') {
        this.$ROUTE.go('/pages/subpackage/housing-resources/housing-detail/index', { projectId: id })
      } else if (this.type == 'recommendRoomType') {
        this.$ROUTE.go('/pages/subpackage/housing-resources/room-detail/index', { roomTypeId: room_type_id, projectId: project_id })
      }
    },
  },
}
</script>

<style lang="scss" scoped>
.#{prefixCls('list-block-container')} {
  .room-container {
    width: 100%;
    display: flex;
    margin-top: 20rpx;
    overflow-x: scroll;
  }
  .room-item {
    width: max-content;
    min-width: 100%;
    display: flex;
    width: max-content;
    .room-card {
      width: 308rpx;
      position: relative;
      margin-right: 20rpx;
      image,
      image {
        width: 308rpx;
        height: 232rpx;
        border-radius: 16rpx;
      }
      .tab-video {
        position: absolute;
        left: 16rpx;
        top: 16rpx;
        width: 40rpx;
        height: 40rpx;
      }
      .room-name {
        margin-top: 16rpx;
        font-size: 28rpx;
        font-weight: bold;
        color: #222222;
        overflow: hidden;
        text-overflow: ellipsis;
        width: 308rpx;
      }
      .room-tag {
        display: flex;
        flex-wrap: wrap;
        margin-top: 10rpx;
        .tag-item {
          padding: 4rpx 8rpx;
          font-size: 22rpx;
          font-weight: 400;
          background-color: #f5f5f5;
          color: #999;
          border-radius: 8rpx;
          margin-right: 8rpx;
          margin-bottom: 8rpx;
        }
      }
      .room-area {
        margin-top: 6rpx;
        font-size: 22rpx;
        font-weight: 400;
        color: #666666;
        line-height: 32rpx;
        overflow: hidden;
        text-overflow: ellipsis;
        width: 308rpx;
      }
      .room-price {
        font-size: 32rpx;
        font-weight: bold;
        color: $uv-price-primary;
        line-height: 32rpx;
        display: flex;
        align-items: center;
        .unit {
          margin-left: 8rpx;
          font-size: 20rpx;
          color: #999999;
        }
      }
    }
  }
}
</style>
